<?php
/**
 * ajax验证
 *
 **/
define ( 'IN_templates', "admin" );
include (dirname(__FILE__)."/../includes/init.php");//全局变量

//动作
$act=trim(isset($_POST['act'])?$_POST['act']:"");
//提示消息
$msg="";
//是否执行操作
$msgsuccess="0";//0表示不执行  1表示执行

switch ($act){

	case "checkadmin":
		$adminid=trim(!empty($_POST['adminid'])?$_POST['adminid']:"");
		//原管理员用户名
		$fuser=trim(!empty($_POST['fuser'])?$fun->checkInput($_POST['fuser']):"");
		//新管理员用户名
		$user=trim(!empty($_POST['user'])?$fun->checkInput($_POST['user']):"");
		$tb_admin="`".$tbprefix."admin`";

		if($fuser){
			$adminInfo=$db->get_all("SELECT `adminid` FROM ".$tb_admin." WHERE `username`='".$fuser."' ".($adminid?"AND `adminid`<>'".$adminid."'":"")." AND 1");
			$msgsuccess=1;
		}
		elseif($user){
			$adminInfo=$db->get_all("SELECT `adminid` FROM ".$tb_admin." WHERE `username`='".$user."' ".($adminid?"AND `adminid`<>'".$adminid."'":"")." AND 1");
			$msgsuccess=1;
		}else{
			$msg='{"root":[{"status":"false","Description":"验证失败"}]}';
		}
		if($msgsuccess==1){
			if(empty($adminInfo[0]['adminid'])){
				$msg='{"root":[{"status":"true","Description":"可使用"}]}';
			}else{
				$msg='{"root":[{"status":"false","Description":"已存在"}]}';
			}
		}
		break;

	case "":
		$msg="ErrorPage";
		break;

	default:
		$msg='{"root":[{"status":"false","Description":"操作失败"}]}';
		break;
}

echo $msg;

?>